import http from '@/api/request';

/**
 * 用户登录
 * @param username 用户名
 * @param password 密码
 * @returns 用户信息
 */
export const login = async (username: string, password: string) => {
  try {
    const response = await http.post('/auth/login', { username, password });
    return response.data;
  } catch (error) {
    console.error('登录失败', error);
    throw error;
  }
};

/**
 * 获取用户信息
 * @returns 用户信息
 */
export const getUserInfo = async () => {
  try {
    const response = await http.get('/user/info');
    return response.data;
  } catch (error) {
    console.error('获取用户信息失败', error);
    throw error;
  }
};

/**
 * 退出登录
 */
export const logout = async () => {
  try {
    await http.post('/auth/logout');
  } catch (error) {
    console.error('退出登录失败', error);
    throw error;
  }
};

// 其他登录相关接口...
